//
// Copyright (c) 2009 Tridium, Inc.
// Licensed under the Academic Free License version 3.0
//
// History:
//   24 Feb 09  Dan Giorgis  Creation
//

#include "sedona.h"

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/ioctl.h>


////////////////////////////////////////////////////////////////
// Native Methods
////////////////////////////////////////////////////////////////


Cell vonplusBasic_VonplusDigitalOutput_set(SedonaVM* vm, Cell* params)
{

    int32_t on = params[0].ival;

	int32_t led_no = params[1].ival;

	int fd;
	fd = open("/dev/leds0", 0);
	if (fd < 0) {
		fd = open("/dev/leds", 0);
	}
	if (fd < 0) {
		perror("open device leds");
		exit(1);
	}
	ioctl(fd, on, led_no);
	close(fd);

 //////////////////////////////////////////////////////


  
  Cell result;
  
  result.ival = led_no; 
   
  return result;
  
  

}












